package ru.st.selenium.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/*
 * Class that extracts properties from the prop file.
 * 
 * @author Sebastiano Armeli-Battana
 */
public class PropertyLoader {

	private static final String PROP_FILE = "/application.properties";
//	private static final String PROP_FILE = "./src/main/resources/application.properties";

	public static String loadProperty(String name) {
		Properties props = new Properties();
		try {
//            xxx();
			props.load(PropertyLoader.class.getResourceAsStream(PROP_FILE));
//			props.load(new BufferedReader(new FileReader(PROP_FILE)));
		} catch (IOException e) {
			e.printStackTrace();
		}

		String value = "";

		if (name != null) {
			value = props.getProperty(name);
		}
		return value;
	}

//    private static void xxx(){
//        BufferedReader br = null;
//
//        try {
//
//            String sCurrentLine;
//
//            br = new BufferedReader(new FileReader(PROP_FILE));
//
//            while ((sCurrentLine = br.readLine()) != null) {
//                System.out.println(sCurrentLine);
//            }
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        } finally {
//            try {
//                if (br != null)br.close();
//            } catch (IOException ex) {
//                ex.printStackTrace();
//            }
//        }
//    }
}